package com.cn.delan.jdbc.mysql;

import javax.sql.DataSource;

import com.cn.delan.jdbc.JDBCUtil;
/**
 * MYSQL对应的JDBC工具类
 * @author BingGo
 *
 */
public class MYSQLUtil extends JDBCUtil {
	
	
	public MYSQLUtil(DataSource dataSource) {
		super(dataSource);
	}
	@Override
	protected String compile(String sql) {
		String compileSQL = sql;
		//获取翻页器的起始编码和页容量
		int startNo = this.getPage().getStartNo();
		int pageCount = this.getPage().getPageCount();
		if(sql.indexOf("limit")!=-1){
			compileSQL = "select * from ("+sql+") as curpage limit "+startNo+","+pageCount;
		}else{
			compileSQL = sql + " limit "+startNo+","+pageCount;
		}
		return compileSQL;
	}

}
